package com.ruoyi.quartz.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseBanner;
import com.ruoyi.quartz.domain.BaseProduct;
import com.ruoyi.quartz.domain.BaseType;
import com.ruoyi.quartz.service.IBaseBannerService;
import com.ruoyi.quartz.service.IBaseInfoService;
import com.ruoyi.quartz.service.IBaseProductService;
import com.ruoyi.quartz.service.IBaseTypeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/front/base")
public class AppletsController extends BaseController {

    @Resource
    private IBaseProductService iBaseProductService;

    @Resource
    private IBaseBannerService iBaseBannerService;

    @Resource
    private IBaseTypeService iBaseTypeService;

    @Resource
    private IBaseInfoService iBaseInfoService;

    /**
     * 查询产品列表
     */
    @Anonymous
    @GetMapping("/productList")
    public TableDataInfo list(BaseProduct baseProduct)
    {
        startPage();
        List<BaseProduct> list = iBaseProductService.selectAll(baseProduct);
        return getDataTable(list);
    }

    @Anonymous
    @GetMapping("/baseInfo/{id}")
    public AjaxResult getBaseInfo(@PathVariable Integer id)
    {
        return success(iBaseInfoService.selectBannerById(id));
    }


    @Anonymous
    @GetMapping("/typeList")
    public TableDataInfo list(BaseType baseType)
    {
        startPage();
        List<BaseType> list = iBaseTypeService.selectAll(baseType);
        return getDataTable(list);
    }

    /**
     * 查询产品详情
     */
    @Anonymous
    @GetMapping(value = "/getProductDetail/{id}")
    public AjaxResult getInfo(@PathVariable Integer id)
    {
        return success(iBaseProductService.selectProductById(id));
    }

    @Anonymous
    @GetMapping("/bannerList")
    public TableDataInfo list(BaseBanner baseBanner)
    {
        startPage();
        List<BaseBanner> list = iBaseBannerService.selectAll(baseBanner);
        return getDataTable(list);
    }

}
